package de.mhus.lib.mandala.form;

import de.mhus.lib.mandala.Response;

public class MultipleSelect extends Select {

	public MultipleSelect(String id, String caption, String ...valuecaption) {
		super(id, caption, valuecaption);
	}

	@Override
	protected void doRenderEdit(Response out) {
		out.startTag("select", "form-control", null, "id", getId(), "multiple", "multiple" );
		for (Option option : options) {
			out.startTag("option", null, null, "value", option.getValue());
			out.printEncoded(option.getCaption());
			out.endTag("option");
		}
		out.endTag("select");
	}

	@Override
	protected void doRenderView(Response out) {
		// TODO  print caption as static text
		out.startTag("select", "form-control", null, "id", getId(), "multiple", "multiple", "disabled", "disabled" );
		for (Option option : options) {
			out.startTag("option", null, null, "value", option.getValue());
			out.printEncoded(option.getCaption());
			out.endTag("option");
		}
		out.endTag("select");
	}

}
